	;EPRINT EX CP/MUGUK VOL 8
	;
	ORG	00100H
X0000	EQU	00000H
Y0001	EQU	00001H
X0005	EQU	00005H
Y0006	EQU	00006H
Y005C	EQU	0005CH
Y005D	EQU	0005DH
Y06D0	EQU	006D0H
Y06D2	EQU	006D2H
Y06D4	EQU	006D4H
Y06D6	EQU	006D6H
	CALL	A0140
	DEFB	'Epsom MX-80 '
	DEFB	'File Print Utility '
	DEFB	'V1.0',0DH,0AH
	DEFB	'$ (C) '
	DEFB	'Phil Wheeler '
	DEFB	'1981 '
A0140:	POP	DE
	LD	C,9
	CALL	X0005
	LD	SP,006F5H
	LD	A,(Y005D)
	CP	' '
	JP	NZ,A02C2	;NO FILENAME
	CALL	A0570
	DEFB	007H	;BELL
	DEFB	'Syntax '
	DEFB	'error.'
	DEFB	' Use:',0DH,0AH
	DEFB	'EPRINT '
	DEFB	'file1/sw1/sw2 '
	DEFB	'file2/etc '
	DEFB	'...',0DH,0AH
	DEFB	'Where '
	DEFB	'filenames '
	DEFB	'may be '
	DEFB	'ambiguous',0DH,0AH
	DEFB	'/P - Print '
	DEFB	'filename '
	DEFB	'on each page',0DH,0AH
	DEFB	'/I - Ignore '
	DEFB	'embedded '
	DEFB	'form feeds',0DH,0AH
	DEFB	'/A - inhibit '
	DEFB	'Auto page '
	DEFB	'feeds',0DH,0AH
	DEFB	'/E - Emphasized '
	DEFB	'print mode',0DH,0AH
	DEFB	'/D - Double '
	DEFB	'print mode',0DH,0AH
	DEFB	'/C - Condensed '
	DEFB	'print mode',0DH,0AH
	DEFB	'/R - Reset '
	DEFB	'print mode',0DH,0AH
	DEFB	'/F - inhibit '
	DEFB	'FF at end of file',0DH,0AH
	DEFB	'Each switch '
	DEFB	'stays in effect '
	DEFB	'until change'
	DEFB	'd'+080H
	JP	X0000
;
A02C2:	LD	HL,(Y0006)
	LD	DE,00085H
	AND	A
	SBC	HL,DE
	LD	(Y06D0),HL	;SET RAMTOP
	CALL	A05C5
	DEFB	018H	;CANCELS CONDENSED MODE
	DEFB	00DH
	DEFB	01BH
	DEFB	044H	;DEFINE TAB
	DEFB	008H	;8 SPACES
	DEFB	010H	;16 SPACES ETC
	DEFB	018H
	DEFB	020H
	DEFB	028H
	DEFB	030H
	DEFB	038H
	DEFB	040H
	DEFB	048H
	DEFB	080H
A02DF:	LD	IX,D0649
	LD	HL,(D0647)
	LD	A,(HL)
	AND	A
	JP	Z,X0000
	CP	020H
	JR	NZ,A02F5
	INC	HL
	LD	(D0647),HL
	JR	A02DF
;
A02F5:	CALL	A0461
	CALL	A0405
A02FB:	LD	HL,(D064C)
	LD	DE,(D064E)
	CALL	A05D1
	JR	Z,A02DF
	LD	DE,0005CH
	LD	BC,0000CH
	LDIR
	LD	(D064C),HL
	LD	B,015H
	XOR	A
A0315:	LD	(DE),A
	INC	DE
	DJNZ	A0315
	CALL	A05DB
	JR	C,A035F
	CALL	A05F1
	CP	01AH
	JR	Z,A034E
	PUSH	AF
	CALL	A0570
	DEFB	'Printing'
	DEFB	' '+080H
	CALL	A0538
	XOR	A
	LD	(D064A),A
	CALL	A038D
	POP	AF
	CP	00CH
	CALL	NZ,A0364
A0342:	CALL	A05F1
	CP	01AH
	JR	Z,A034E
	CALL	A0364
	JR	A0342
;
A034E:	BIT	3,(IX+000H)
	JR	NZ,A0358
	CALL	A05C5
	ADC	A,H
A0358:	CALL	A0570
	DEC	C
	ADC	A,D
	JR	A02FB
;
A035F:	CALL	A044B
	JR	A02FB
;
A0364:	CP	00CH
	JR	Z,A0383
	CP	00AH	;LF
	JP	NZ,A057C
	LD	A,(D064B)
	INC	A
	LD	(D064B),A	;INCREMENT LINE COUNT
	CP	03FH	;IS IT>63
	JR	C,A037E
	BIT	2,(IX+000H)
	JR	Z,A0388
A037E:	LD	A,00AH	;LF
	JP	A057C
;
A0383:	BIT	1,(IX+000H)
	RET	NZ
A0388:	LD	A,00CH
	CALL	A057C
A038D:	LD	A,(D064A)
	INC	A
	LD	(D064A),A	;INCREMENT PAGE NUMBER
	XOR	A
	LD	(D064B),A
	BIT	0,(IX+000H)
	RET	Z	;NO HEADERS
	CALL	A05C5	;PRINT HEADER
	DEFB	'File'
	DEFB	':'+080H
	LD	HL,0005DH
	LD	B,008H
	CALL	A03FB
	CALL	A05C5
	XOR	(HL)
	LD	B,003H
	CALL	A03FB
	CALL	A05C5
	DEFB	'  Page'
	DEFB	' '+080H
	LD	A,(D064A)
	LD	E,A
	LD	C,000H
	LD	D,064H
	CALL	A03E3
	LD	D,00AH
	CALL	A03E3
	LD	A,E
	ADD	A,030H
	CALL	A057C
	CALL	A05C5
	DEC	C
	LD	A,(BC)
	DEC	C
	ADC	A,D
	LD	A,002H
	LD	(D064B),A
	RET
;
A03E3:	LD	B,030H
	LD	A,E
	JR	A03E9
;
A03E8:	INC	B
A03E9:	SUB	D
	JR	NC,A03E8
	ADD	A,D
	LD	E,A
	LD	A,B
	CP	030H
	JR	NZ,A03F6
	LD	A,C
	AND	A
	RET	Z
A03F6:	INC	C
	LD	A,B
	JP	A057C
;
A03FB:	LD	A,(HL)
	INC	HL
	CP	021H
	CALL	NC,A057C
	DJNZ	A03FB
	RET
;
A0405:	LD	DE,T0650
	LD	C,01AH
	CALL	X0005	;SET DMA
	LD	HL,006F5H
	LD	(D064C),HL
	LD	(D064E),HL
	LD	C,011H	;SEARCH FIRST
	LD	DE,0005CH
	CALL	X0005
	CP	0FFH
	JR	Z,A044B
A0422:	ADD	A,A
	ADD	A,A
	ADD	A,A
	ADD	A,A
	ADD	A,A
	LD	HL,T0650
	CALL	A05D6
	LD	A,(Y005C)
	LD	(HL),A
	LD	DE,(D064E)
	LD	BC,0000CH
	LDIR			;MOVE FILENAME
	LD	(D064E),DE
	LD	C,012H		;SEARCH NEXT
	LD	DE,0005CH
	CALL	X0005
	CP	0FFH
	JR	NZ,A0422
	RET
;
A044B:	CALL	A0570
	DEFB	'No file -'
	DEFB	' '+080H
	CALL	A0538
	CALL	A0570
	DEFB	00DH
	DEFB	08AH
	RET
;
A0461:	LD	DE,0005CH
	XOR	A
	LD	B,00CH
A0467:	LD	(DE),A
	INC	DE
	LD	A,020H
	DJNZ	A0467
A046D:	LD	DE,0005DH
	LD	B,008H
A0472:	CALL	A04BD
	RET	Z
	CP	03AH
	JR	NZ,A0485
	DEC	DE
	LD	A,(DE)
	DEC	A
	AND	00FH
	INC	A
	LD	(Y005C),A
	JR	A046D
;
A0485:	CP	02EH
	JR	Z,A0496
	CP	02AH
	JR	Z,A0493
	LD	(DE),A
	INC	DE
	DJNZ	A0472
	JR	A0496
;
A0493:	CALL	A04B6
A0496:	LD	B,003H
	LD	DE,00065H
A049B:	CALL	A04BD
	RET	Z
	CP	02EH
	JR	Z,A049B
	CP	02AH
	JR	Z,A04B1
	LD	(DE),A
	INC	DE
	DJNZ	A049B
A04AB:	CALL	A04BD
	JR	NZ,A04AB
	RET
;
A04B1:	CALL	A04B6
	JR	A04AB
;
A04B6:	LD	A,03FH
	LD	(DE),A
	INC	DE
	DJNZ	A04B6
	RET
;
A04BD:	LD	HL,(D0647)
	LD	A,(HL)
	AND	A
	RET	Z
	CP	' '
	RET	Z
	INC	HL
	LD	(D0647),HL
	CP	'/'
	RET	NZ
	LD	A,(HL)
	INC	HL
	LD	(D0647),HL
	CP	'P'	;PRINT FILENAME ON EACH PAGE
	JR	NZ,A04E0
	LD	A,(D0649)
	XOR	001H
	LD	(D0649),A
	JR	A04BD
;
A04E0:	CP	'I'	;IGNORE FF?
	JR	NZ,A04EE
	LD	A,(D0649)
	XOR	002H
	LD	(D0649),A
	JR	A04BD
;
A04EE:	CP	'A'	;INHIBIT AUTO PAGE?
	JR	NZ,A04FC
	LD	A,(D0649)
	XOR	004H
	LD	(D0649),A
	JR	A04BD
;
A04FC:	CP	'C'	;CONDENSED
	JR	NZ,A0506
	CALL	A05C5
	DEFB	08FH	;CONDENSED MODE
	JR	A04BD
;
A0506:	CP	'D'	;DOUBLE
	JR	NZ,A0511
	CALL	A05C5
	DEFB	01BH
	DEFB	0C7H	;"G" DOUBLE STRIKE MODE
	JR	A04BD
;
A0511:	CP	'E'	;EMPHASIZED
	JR	NZ,A051C
	CALL	A05C5
	DEFB	01BH
	DEFB	0C5H	;EMPASIZED MODE
	JR	A04BD
;
A051C:	CP	'R'	;RESET
	JR	NZ,A052A
	CALL	A05C5
	DEFB	012H	;CANCEL CONDENSED MODE
	DEFB	01BH
	DEFB	046H	;CANCEL EMPHASIZED MODE
	DEFB	01BH
	DEFB	0C8H	;CANCEL DOUBLE STRIKE MODE
	JR	A04BD
;
A052A:	CP	'F'	;NO FORM FEED
	JR	NZ,A04BD
	LD	A,(D0649)
	XOR	008H
	LD	(D0649),A
	JR	A04BD
;
A0538:	LD	A,(Y005C)
	AND	A
	JR	Z,A0547
	ADD	A,040H
	CALL	A055F
	CALL	A0570
	CP	D
A0547:	LD	HL,0005DH
	LD	B,008H
	CALL	A0555
	CALL	A0570
	XOR	(HL)
	LD	B,003H
A0555:	LD	A,(HL)
	INC	HL
	CP	021H
	CALL	NC,A055F
	DJNZ	A0555
	RET
;
A055F:	PUSH	AF
	PUSH	BC
	PUSH	DE
	PUSH	HL
	AND	07FH
	LD	E,A
	LD	C,002H
	CALL	X0005
	POP	HL
	POP	DE
	POP	BC
	POP	AF
	RET
;
A0570:	EX	(SP),HL
A0571:	LD	A,(HL)
	INC	HL
	CALL	A055F
	BIT	7,A
	JR	Z,A0571
	EX	(SP),HL
	RET
;
A057C:	PUSH	AF
	PUSH	BC
	PUSH	DE
	PUSH	HL
	PUSH	AF
A0581:	LD	C,00BH	;KYBD STATUS
	CALL	X0005
	AND	A
	JR	Z,A05A9
	LD	C,001H	;INPUT KYBD
	CALL	X0005
	AND	07FH
	CP	003H	;CTL C
	JR	NZ,A05A9
	CALL	A0570
	DEFB	00DH
	DEFB	00AH
	DEFB	'** Aborted *'
	DEFB	'*'+080H
	JP	X0000
;
A05A9:	LD	HL,(Y0001)
	LD	DE,0002AH
	ADD	HL,DE
	CALL	A05C4
	AND	A
	JR	Z,A0581
	POP	AF
	AND	07FH
	LD	E,A
	LD	C,005H
	CALL	X0005
	POP	HL
	POP	DE
	POP	BC
	POP	AF
	RET
;
A05C4:	JP	(HL)
;
A05C5:	EX	(SP),HL
A05C6:	LD	A,(HL)
	CALL	A057C
	INC	HL
	BIT	7,A
	JR	Z,A05C6
	EX	(SP),HL
	RET
;
A05D1:	AND	A
	SBC	HL,DE
	ADD	HL,DE
	RET
;
A05D6:	ADD	A,L
	LD	L,A
	RET	NC
	INC	H
	RET
;
A05DB:	LD	DE,0005CH
	LD	C,00FH
	CALL	X0005	;OPEN FILE
	INC	A
	SCF
	RET	Z
	LD	HL,0
	LD	(Y06D4),HL
	XOR	A
	LD	(Y06D6),A
	RET
;
A05F1:	PUSH	BC
	PUSH	HL
	LD	HL,(Y06D2)
	LD	BC,(Y06D4)
	LD	A,B
	OR	C
	CALL	Z,A060D
	LD	A,(HL)
	CPI
	AND	A
	LD	(Y06D2),HL
	LD	(Y06D4),BC
A060A:	POP	HL
	POP	BC
	RET
;
A060D:	LD	A,(Y06D6)
	AND	A
	SCF
	LD	A,01AH
	JR	NZ,A060A
	LD	DE,(D064E)
A061A:	PUSH	BC
	PUSH	DE
	LD	C,01AH
	CALL	X0005	;SET DMA
	LD	DE,0005CH
	LD	C,014H
	CALL	X0005	;READ SEQ
	POP	DE
	POP	BC
	LD	(Y06D6),A
	AND	A
	JR	NZ,A0643
	LD	HL,00080H
	PUSH	HL
	ADD	HL,DE
	EX	DE,HL
	POP	HL
	ADD	HL,BC
	LD	B,H
	LD	C,L
	LD	HL,(Y06D0)
	AND	A
	SBC	HL,DE
	JR	NC,A061A
A0643:	LD	HL,(D064E)
	RET
;
D0647:	DEFB	081H
	DEFB	000H
D0649:	DEFB	000H
D064A:	DEFB	000H
D064B:	DEFB	000H
D064C:	DEFB	000H
	DEFB	000H
D064E:	DEFB	000H
	DEFB	000H
T0650:	DEFB	000H
	END
